package com.hmall.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hmall.domain.po.Information;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author HBQ
 * @since 2025-10-22
 */
public interface InformationMapper extends BaseMapper<Information> {

    @Update("UPDATE information " +  // 必须指定表名（替换为你的实际表名）
            "SET name=#{information.name}, " +
            "gender=#{information.gender}, " +
            "age=#{information.age}, " +
            "position=#{information.position}, " +
            "region=#{information.region}, " +
            "image=#{information.image}, " +
            "introduce=#{information.introduce} " +
            "WHERE user_id=#{userId}")  // 必须添加WHERE条件，指定更新哪条记录
    boolean saveUser(@Param("information") Information information, @Param("userId") Long userId);

    @Insert("UPDATE information " +
            "SET name = #{information.name}, " +
            "gender = #{information.gender}, " +
            "age = #{information.age}, " +
            "position = #{information.position}, " +
            "region = #{information.region}, " +
            "image = #{file}, " +
            "introduce = #{information.introduce} " +
            "WHERE user_id = #{userId}")
    boolean updateInformation(@Param("information") Information information,@Param("file") MultipartFile file,@Param("userId") LambdaQueryWrapper<Information> userid);
}
